﻿using Api1.Model;
using System;

namespace Api1.Service
{

    class CabinetService : BaseService<Cabinet>
    {
        private static CabinetService instance;
   
        private CabinetService() {

        }
        public static CabinetService GetInstance() {
            if (instance == null)
            {
                instance = new CabinetService();
            }
            return instance;
        }
        /// <summary>
        /// 新增柜子存储
        /// </summary>
        /// <param name="interfaces">会员信息</param>
        /// <param name="cabinet_nos">柜子号</param>
        /// <returns>新增的id</returns>
        public void AddCabinet(Interfaces interfaces,String cabinet_nos) {
            if (!String.IsNullOrWhiteSpace(cabinet_nos)) {
                String[] temp=  cabinet_nos.Split(',');
                if (temp != null && temp.Length > 0) {
                    foreach (String no in temp) {
                        if (!String.IsNullOrWhiteSpace(no) && !no.Equals("0")) {
                            Cabinet cabinet = new Cabinet()
                            {
                                Cabinet_No = no,
                                Name = interfaces.Name,
                                Mobile = interfaces.Mobile,
                                Card_No = interfaces.Card_No,
                                Owner_Type = interfaces.Owner_Type,
                                Member_Id = interfaces.Member_Id
                                
                            };
                            Insert(cabinet);
                        }
                    }
                }
            }
        }
    }
}
